package com.ruoyi.report.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.report.domain.PwReport;
import com.ruoyi.report.service.IPwReportService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 举报有奖Controller
 * 
 * @author ruoyi
 * @date 2025-07-26
 */
@RestController
@RequestMapping("/report/report")
public class PwReportController extends BaseController
{
    @Autowired
    private IPwReportService pwReportService;

    /**
     * 查询举报有奖列表
     */
    @PreAuthorize("@ss.hasPermi('report:report:list')")
    @GetMapping("/list")
    public TableDataInfo list(PwReport pwReport)
    {
        startPage();
        List<PwReport> list = pwReportService.selectPwReportList(pwReport);
        return getDataTable(list);
    }

    /**
     * 导出举报有奖列表
     */
    @PreAuthorize("@ss.hasPermi('report:report:export')")
    @Log(title = "举报有奖", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, PwReport pwReport)
    {
        List<PwReport> list = pwReportService.selectPwReportList(pwReport);
        ExcelUtil<PwReport> util = new ExcelUtil<PwReport>(PwReport.class);
        util.exportExcel(response, list, "举报有奖数据");
    }

    /**
     * 获取举报有奖详细信息
     */
    @PreAuthorize("@ss.hasPermi('report:report:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(pwReportService.selectPwReportById(id));
    }

    /**
     * 新增举报有奖
     */
    @PreAuthorize("@ss.hasPermi('report:report:add')")
    @Log(title = "举报有奖", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PwReport pwReport)
    {
        return toAjax(pwReportService.insertPwReport(pwReport));
    }

    /**
     * 修改举报有奖
     */
    @PreAuthorize("@ss.hasPermi('report:report:edit')")
    @Log(title = "举报有奖", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PwReport pwReport)
    {
        return toAjax(pwReportService.updatePwReport(pwReport));
    }

    /**
     * 删除举报有奖
     */
    @PreAuthorize("@ss.hasPermi('report:report:remove')")
    @Log(title = "举报有奖", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(pwReportService.deletePwReportByIds(ids));
    }
}
